//
//  BaseVC.swift
//  WBSwift
//
//  Created by maker on 2016/11/9.
//  Copyright © 2016年 maker. All rights reserved.
//

import UIKit

class BaseVC: UITableViewController {
    var isLogin = false
    lazy var vistorView : VistorView = VistorView.creatXib()
    
    override func loadView() {
        isLogin = UserInfoViewModel.shareInstance.isLogin
        isLogin ? super.loadView() : setupVistorView()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setNavigationItem()
    }

}

//MARK:==========访客 UI==========

extension BaseVC{
    ///创建访客视图
   fileprivate func setupVistorView() {
        view = vistorView
        vistorView.registerBtn.addTarget(self, action: #selector(BaseVC.registerClick), for: .touchUpInside)
        vistorView.loginBtn.addTarget(self, action: #selector(BaseVC.loginClick), for: .touchUpInside)
    }
    
    ///创建左右导航按钮
    @objc fileprivate func setNavigationItem () {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .plain, target: self, action: #selector(BaseVC.registerClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .plain, target: self, action: #selector(BaseVC.loginClick))
    }
}

//MARK:==========点击事件==========
extension BaseVC{
    func registerClick () {
        mprint("registerClick")
    }
    func loginClick () {
        
        let auoth = AuothVC()
        
        let NavAuoth = UINavigationController(rootViewController: auoth)
        
        present(NavAuoth, animated: true, completion: nil)
    }
}








